package com.earnings.okhttputils.utils.https;

import android.content.Context;
import android.util.Log;

import com.earnings.okhttputils.utils.OkHttp.utils.Md5Utils;
import com.earnings.okhttputils.utils.OkHttp.utils.PhoneFormatCheckUtils;
import com.earnings.okhttputils.utils.OkHttp.utils.Versions;
import com.earnings.okhttputils.utils.UrlConstant.Constant;
import com.earnings.okhttputils.utils.User;
import com.earnings.okhttputils.utils.bean.YData;
import com.earnings.okhttputils.utils.utils.CommonUtil;

import java.util.Date;
import java.util.HashMap;

/**
 * Created by HOHO on 2017/4/26.
 */

public class HttpMap extends HashMap<String, String> {
    private Context mContext;
    User User;
/*

    public HttpMap() {
        User = CommonUtil.getUser();
        initData();
    }
*/

    public HttpMap(Context context) {
        this.mContext = context;
        User = CommonUtil.getUser();
        initData();
        // ((BaseActivity)context).showProgress();
    }

    private void initData() {
        String currentTime = new Date().getTime() + "";
        String UniqueID = PhoneFormatCheckUtils.getPesudoUniqueID();
        String str = Md5Utils.getMd5User(User.getPhone(), UniqueID, User.getPassword(), currentTime);
        put("unique_id", UniqueID);
        put("user_id", User.getUser_id());
        put("token", User.getToken());
        put("time", currentTime);
        put("sign", str);
        put("client", "Android");
       // put("version", currentTime);

        String version = Versions.getVersionName(mContext);
        put("version", version);

        if (YData.app_type == YData.APP_ZCHB) {
            put("app_type", "2");
        }
        if (YData.app_type == YData.APP_BSSC) {
            put("app_type", "1");

        }

        put("debug",User.getDebugcode()+"");

    }

    @Override
    public String put(String key, String value) {
        Log.e(Constant.TAG, "" + key + ":" + value);
        if (value == null) value = "";
        return super.put(key, value);
    }
}
